<?php
/**
 * Created by PhpStorm.
 * User: o0无忧亦无佈(285753421@qq.com)
 * Date: 15-2-2
 * Time: 下午5:42
 */
/*账户信息*/
class account extends MY_Portal_Controller{

    protected  $user_id;

    function __construct(){

        parent::__construct(); 
        $this->user_id = $this->session->userdata("company_user_id");
        $this->load->model('company/company_base');
    }

    /*
     * 打印店账户中心首页
     */
    function index(){

        $user_info =  $this->company_base->get_user_by_id($this->user_id);
        $this->assign('user',$user_info);

        //$this->display();
    }

    function shop_info(){
        $info = $this->company_base->get_company_users();
        $this->assign('shop',$info);
        $this->display();
    }

    function do_set_info(){
        $this->config->load('document');
        $charge = $this->config->item('price', 'document');
        foreach ($charge as $name=>$value){
                $charge[$name] = $this->input->post($name);
        }
        $data = array(
            'address'   => trim($this->input->post('address')),
            'lng'       => trim($this->input->post('lng')),
            'lat'       =>  trim($this->input->post('lat')),
            'company_name'   =>  trim($this->input->post('company')),
            'charge'    =>  $charge,
			'number'  => $this->input->post('number'),
			'mobile'  => $this->input->post('mobile')
        );

        if(!$data)
            $this->json_response(false,array('field'=>'address'),'更新信息错误');

        $result =  $this->company_base->set_address($this->user_id,$data);

        if(!$result)
            $this->json_response(false,array('field'=>'address'),'更新信息失败');

        $this->json_response(true);
    }

}